//
//  MineHeadView.m
//  ChangChat
//
//  Created by Cocoa on 2019/9/27.
//  Copyright © 2019 yibai. All rights reserved.
//

#import "MineHeadView.h"
#import "YBBaseView.h"

@interface MineHeadView ()


@end

@implementation MineHeadView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}
- (void)setupUI {
    
    UIImage *bgImg = UIImage.k_imgName(@"mine_header_bg");
    self.layer.contents = (id)bgImg.CGImage;
    
    self.iconImgView = [UIImageView new];
    self.nicknameLabel = [UILabel k_labelWithFontSize:15 textColor:UIColor.whiteColor];
    self.mobileLabel = [UILabel k_labelWithFontSize:12 textColor:UIColor.whiteColor];
    self.nicknameLabel.numberOfLines = 2;
    self.qqLabel = [ UILabel k_labelWithFontSize:12 textColor:UIColor.whiteColor];
    self.editIconBtn = UIButton.k_init();
    self.editNicknameBtn = UIButton.k_init();
    UIImageView *rightArrowImgView = [[UIImageView alloc] initWithImage:UIImage.k_imgName(@"arrow_right_white")];
    self.rightArrowImgView = rightArrowImgView;
    UIImageView *editImgView = [[UIImageView alloc] initWithImage:UIImage.k_imgName(@"mine_edit")];
    
    
    
    [self addSubview:self.iconImgView];
    [self addSubview:self.nicknameLabel];
    [self addSubview:self.mobileLabel];
    [self addSubview:self.qqLabel];
    [self addSubview:self.editNicknameBtn];
    [self addSubview:self.editIconBtn];
    [self addSubview:rightArrowImgView];
    [self addSubview:editImgView];
    
    [self.iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_offset(StatusBarHeight + 35 + 15);
        make.left.mas_offset(15);
        make.size.mas_equalTo(CGSizeMake(70, 70));
        make.bottom.mas_offset(-30);
    }];
    self.iconImgView.layer.cornerRadius = 35;
    self.iconImgView.layer.masksToBounds = YES;
    
    [self.nicknameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconImgView.mas_right).offset(5);
        make.top.equalTo(self.iconImgView).mas_offset(10);
    }];
    [self.nicknameLabel setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    [editImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.nicknameLabel);
        make.left.equalTo(self.nicknameLabel.mas_right).offset(5);
    }];
    
    [self.mobileLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nicknameLabel);
        make.top.equalTo(self.nicknameLabel.mas_bottom).offset(10);
    }];
    
    [self.qqLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.mobileLabel.mas_bottom).offset(3);
        make.left.equalTo(self.nicknameLabel);
    }];
    self.qqLabel.hidden = YES;
    
    [rightArrowImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-15);
        make.centerY.equalTo(self.iconImgView);
    }];
    
    [self.editNicknameBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.mas_offset(0);
        make.bottom.equalTo(self.iconImgView.mas_bottom).offset(20);
    }];
    [self.editIconBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.iconImgView);
    }];
    self.iconImgView.image = UIImage.k_imgName(@"placeholder_user");
    self.nicknameLabel.text = @"昵称张三丰";
    self.mobileLabel.text = @"18866668888";
    
    
    UIView *bottomView = [YBBaseView new];
    bottomView.backgroundColor = UIColor.whiteColor;
    [self addSubview:bottomView];
    [bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.mas_offset(0);
        make.height.mas_equalTo(15);
    }];
}

@end
